<?php

require_once ('../util/Constants.php');
//require_once 'Mail/RFC822.php'; 

class Mailer {
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */

    public static function sendMail($an, $betreff, $msg, $email = Constants::MAIL_SENDER) {

        if (Mailer::valid_email($email)) {
           
            if (!mail($an, $betreff, $msg, 'From:' . $email)){
                throw new Exception('Fehler bei der E-Mail Versendung.');
            }
        } else {
            throw new Exception('Fehler bei der E-Mail Validierung.');
        }
    }

    public static function valid_email($email) {
        if ( filter_var($email, FILTER_VALIDATE_EMAIL) ) {
            return true;
        } else {
            return false;
        }
    }
}

?>
